package com.example.yichuangyun.mvvm.ui.activity.view;

import androidx.lifecycle.MutableLiveData;

import com.example.yichuangyun.config.Constant;
import com.example.yichuangyun.model.company.IntellectualPropertyDataModel;
import com.example.yichuangyun.mvvm.base.BaseViewModel;
import com.example.yichuangyun.mvvm.di.retrofit.BaseModel;
import com.example.yichuangyun.mvvm.di.retrofit.BaseNetCallback;

import java.util.List;

public class PatentViewModel extends BaseViewModel {

    public MutableLiveData<List<IntellectualPropertyDataModel.IntellectualPropertyModel>> mutableLiveData = new MutableLiveData<>();

    /**
     * 知识产权
     */
    public void getIntellectualProperty(String eid) {
        addSubscribe(mRetrofitHelper.getIntellectualProperty(eid).subscribeWith(new BaseNetCallback<IntellectualPropertyDataModel>() {

            @Override
            public void onSuccess(BaseModel<IntellectualPropertyDataModel> baseModel) {
                if (Constant.SUCCESS == baseModel.getCode()) {
                    if (null != baseModel.getData()) {
                        IntellectualPropertyDataModel model = baseModel.getData();
                        if (null != model.getPatentsRelationsNews() && model.getPatentsRelationsNews().size() > 0) {
                            mutableLiveData.setValue(model.getPatentsRelationsNews());
                        }
                    }
                }
            }
        }));
    }
}
